﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCBugTracker.ViewModels.BugCreateViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm())
       {%>
    <%: Html.ValidationSummary(true) %>
    <h2>
        New Bug</h2>
    <hr />
    <div id="actionbuttons" style="width: 800px; text-align: right;">
        <p>
            <input type="submit" value="Create" />
            <%: Html.ActionLink("Cancel", "Index", new { projectid = Model.Bug.ProjectID }, new { @class = "button" }) %>
        </p>
    </div>
    <%: Html.HiddenFor(model => model.Bug.ProjectID) %>
    <div class="editor-label" style="float: left; width: 150px">
        <%: Html.LabelFor(model => model.Bug.Title)%>:
    </div>
    <div class="editor-field" style="float: left;">
        <%: Html.TextBoxFor(model => model.Bug.Title, new { style = "width:650px" })%>
        <%: Html.ValidationMessageFor(model => model.Bug.Title)%>
    </div>
    <div class="clear">
    </div>
    <div class="editor-label" style="float: left; width: 150px">
        <%: Html.LabelFor(model => model.Bug.CategoryID)%>:
    </div>
    <div class="editor-field" style="float: left;">
        <%: Html.DropDownListFor(model => model.Bug.CategoryID, new SelectList(Model.ProjectCategories, "CategoryID", "Name", Model.Bug.CategoryID), new { style = "width:200px" })%>
    </div>
    <div class="clear">
    </div>
    <div class="editor-label" style="float: left; width: 150px">
        <%: Html.LabelFor(model => model.Bug.LastUpdate)%>:
    </div>
    <div class="editor-field" style="float: left;">
        <%: String.Format("{0:g}", Model.Bug.LastUpdate)%>
    </div>
    <div class="clear">
    </div>
    <hr />
    <div style="float: left; width: 430px">
        <div class="editor-label" style="float: left; width: 150px">
            <%: Html.LabelFor(model => model.Bug.AssignedUserName)%>:
        </div>
        <div class="editor-field" style="float: left;">
            <%: Html.DropDownListFor(model => model.Bug.AssignedUserName, new SelectList(Model.ProjectMembers, "UserName", "UserName", Model.Bug.AssignedUserName), new { style = "width:200px" })%>
        </div>
        <div class="clear">
        </div>
        <div class="editor-label" style="float: left; width: 150px">
            <%: Html.LabelFor(model => model.Bug.CreatorUserName)%>:
        </div>
        <div class="editor-field" style="float: left;">
            <%: User.Identity.Name %>
        </div>
        <div class="clear">
        </div>
        <div class="editor-label" style="float: left; width: 150px">
            <%: Html.LabelFor(model => model.Bug.DateCreated)%>:
        </div>
        <div class="editor-field" style="float: left;">
            <%: String.Format("{0:g}", Model.Bug.DateCreated)%>
        </div>
        <div class="clear">
        </div>
        <div class="editor-label" style="float: left; width: 150px">
            Project:
        </div>
        <div class="editor-field" style="float: left;">
            <%: Model.ProjectName%>
        </div>
        <div class="clear">
        </div>
    </div>
    <div style="float: left">
        <div class="editor-label" style="float: left; width: 150px">
            <%: Html.LabelFor(model => model.Bug.StatusID)%>:
        </div>
        <div class="editor-field" style="float: left;">
            <%: Html.DropDownListFor(model => model.Bug.StatusID, new SelectList(Model.ProjectStatuses, "StatusID", "Name", Model.Bug.StatusID), new { style = "width:200px" })%>
            <% if (Model.Bug.StatusID != null)
               { %>
            <img id="statusurl" src="<%: ResolveUrl(Model.ProjectStatuses.SingleOrDefault(s => s.StatusID == Model.Bug.StatusID).ImageUrl) %>"
                alt="" />
            <% } %>
        </div>
        <div class="clear">
        </div>
        <div class="editor-label" style="float: left; width: 150px">
            <%: Html.LabelFor(model => model.Bug.PriorityID)%>:
        </div>
        <div class="editor-field" style="float: left;">
            <%: Html.DropDownListFor(model => model.Bug.PriorityID, new SelectList(Model.ProjectPriorities, "PriorityID", "Name", Model.Bug.PriorityID), new { style = "width:200px" })%>
            <% if (Model.Bug.PriorityID != null)
               { %>
            <img id="priorityurl" src="<%: ResolveUrl(Model.ProjectPriorities.SingleOrDefault(p => p.PriorityID == Model.Bug.PriorityID).ImageUrl) %>"
                alt="" />
            <% } %>
        </div>
        <div class="clear">
        </div>
        <div class="editor-label" style="float: left; width: 150px">
            <%: Html.LabelFor(model => model.Bug.MilestoneID)%>:
        </div>
        <div class="editor-field" style="float: left;">
            <%: Html.DropDownListFor(model => model.Bug.MilestoneID, new SelectList(Model.ProjectMilestones, "MilestoneID", "Name", Model.Bug.MilestoneID), new { style = "width:200px" })%>
            <% if (Model.Bug.MilestoneID != null)
               { %>
            <img id="milestoneurl" src="<%: ResolveUrl(Model.ProjectMilestones.SingleOrDefault(m => m.MilestoneID == Model.Bug.MilestoneID).ImageUrl) %>"
                alt="" />
            <% } %>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="clear">
    </div>
    <br />
    <%: Html.TextAreaFor(model => model.Bug.Description, 15, 97, null)%>
    <br />
    <% } %>
    <script type="text/javascript">
        $(function () {
            tinyMCE.init({
                // General options
                mode: "exact",
                elements: "Bug.Description",
                theme: "advanced",
                skin: "o2k7",
                theme_advanced_toolbar_location: "top",
                theme_advanced_toolbar_align: "left",
                theme_advanced_statusbar_location: "bottom",
                theme_advanced_resizing: true,
            });

        });

         $('#Bug_MilestoneID').change(function () {
            var url = '/Project/GetMilestoneURL/' + $("#Bug_MilestoneID").val();
            $.ajax({
                type: 'POST',
                url: url,
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (response) {
                    $('#milestoneurl').attr("src", response);
                }
            });
        });

        $('#Bug_PriorityID').change(function () {
            var url = '/Project/GetPriorityURL/' + $("#Bug_PriorityID").val();
            $.ajax({
                type: 'POST',
                url: url,
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (response) {
                    $('#priorityurl').attr("src", response);
                }
            });
        });

        $('#Bug_StatusID').change(function () {
            var url = '/Project/GetStatusURL/' + $("#Bug_StatusID").val();
            $.ajax({
                type: 'POST',
                url: url,
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (response) {
                    $('#statusurl').attr("src", response);
                }
            });
        });
    </script>
</asp:Content>
